package sii.fb.emotion.computProbability;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import sii.fb.emotion.Main;
import sii.fb.emotion.bean.Post;
import sii.fb.emotion.bean.User;

public class ProbabilityBasedOnPersonality {

	//Probability of occurrences of emotions in status updates from users with different positive personality traits.
		public  void personality2Emotion(Map<Long, User> users, Map<Long, List<Post>> posts){
			SupportMethod cp = new SupportMethod();
			User u;
			Map<String, Float[] > emot2person =  new HashMap<String, Float[]>();
			int[] post_pers = new int[5];
			
			String[] personality;
			for(Long l:posts.keySet()){
				u = users.get(l);
				personality = u.getPersonality();		
				List<Post> post = posts.get(l);
				if(personality[0]!=null){
					for(Post p: post){
						float[] emotionPost = p.getEmotion();
						for(int i=0; i<personality.length; i++){
							if(personality[i]!=null){
								if(personality[i].equals("Openess"))
									post_pers[0]++;
								if(personality[i].equals("Conscientiouness"))
									post_pers[1]++;
								if(personality[i].equals("Extroversion"))
									post_pers[2]++;
								if(personality[i].equals("Aggreableness"))
									post_pers[3]++;
								if(personality[i].equals("Neuroticism"))
									post_pers[4]++;
								if(emot2person.get(personality[i])!=null){
									cp.updateEmotionArray(emotionPost, emot2person.get(personality[i]));
								}else{
									emot2person.put(personality[i], new Float[]{0F,0F,0F,0F,0F,0F,0F,0F,0F,0F,0F});
									cp.updateEmotionArray(emotionPost, emot2person.get(personality[i]));
								}
							}
						}
					}
				}
			}
			Main.print += "----------PERSONALITY----------\n";
			for(String s : emot2person.keySet()){
				if(s.equals("Openess")) cp.normalizeListPostEm(emot2person.get(s), post_pers[0]);
				if(s.equals("Conscientiouness")) cp.normalizeListPostEm(emot2person.get(s), post_pers[1]);
				if(s.equals("Extroversion")) cp.normalizeListPostEm(emot2person.get(s), post_pers[2]);
				if(s.equals("Aggreableness")) cp.normalizeListPostEm(emot2person.get(s), post_pers[3]);
				if(s.equals("Neuroticism")) cp.normalizeListPostEm(emot2person.get(s), post_pers[4]);

			}
			
		}
}
